package com.yunji.base.service;

import com.yunji.base.convert.SiteAuditConvert;
import com.yunji.base.dao.ISiteAuditDao;
import com.yunji.base.dao.ISiteScaleDao;
import com.yunji.base.domain.SiteAuditDO;
import com.yunji.base.params.SiteAuditParam;
import com.yunji.base.vo.SiteAuditVO;
import com.yunji.common.base.IModifyStatusBaseBO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SiteAuditService {

    @Resource
    private ISiteAuditDao siteAuditDao;

    @Resource
    private ISiteScaleDao siteScaleDao;

    public boolean checkUniqueAudit(String siteTel) {
        return siteAuditDao.checkUniqueAudit(siteTel);
    }

    public boolean save(SiteAuditDO siteAudit) {
        return siteAuditDao.save(siteAudit);
    }

    public List<SiteAuditVO> search(SiteAuditParam dto) {
        return SiteAuditConvert.domainTOVOList(siteAuditDao.search(dto),siteScaleDao);
    }

    public SiteAuditVO selectVO(Long auditId) {
        return SiteAuditConvert.domainTOVO(siteAuditDao.getById(auditId),siteScaleDao);
    }

    public boolean update(SiteAuditDO update) {
       return siteAuditDao.updateById(update);
    }

    public SiteAuditDO select(Long auditId) {
        return siteAuditDao.getById(auditId);
    }

    public boolean modifyStatus(Long auditId, Integer newStatus, List<Integer> oldStatus ) {
        return siteAuditDao.modifyStatus(new IModifyStatusBaseBO<Long>(){
            @Override
            public Long getId() {
                return auditId;
            }
            @Override
            public Integer getNewStatus() {
                return newStatus;
            }
            @Override
            public List<Integer> getOldStatus() {
                return oldStatus;
            }
        });
    }
}
